<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<div id="app">
    <h1>用户名:<input type="text" v-model="message"/></h1> <br/>
    <h1>您输入的用户名是: {{message}}</h1>
</div>
</body>
<script>
    var app = new Vue({
        el:"#app",
        data:{
            message:"",
            person:{"name":"heima", "age":13}
        },
        //watch监听
        watch:{
            //监听message属性值,newValue代表新值,oldValue代表旧值
            message(newValue, oldValue){
                console.log("新值：" + newValue + "；旧值：" + oldValue);
            },
            //监控person对象的值,对象的监控只能获取新值
            person: {
                //开启深度监控；监控对象中的属性值变化
                deep: true,
                //获取到对象的最新属性数据(obj代表新对象)
                handler(obj){
                    console.log("name = " + obj.name + "; age=" + obj.age);
                }
            }
        }
    });

</script>
</html>